import { getTitleName } from "@/api/exam/numb";
const state = {
    questionType: []
}

const mutations = {
    INIT: (state, obj) => {
        console.log('INIT 触发');
        if (state.questionType.length == 0) {
            for (let i = 0; i < obj.length; i++) {
                state.questionType.push(obj[i])
            }
            // state.questionType = obj
            console.log(state.questionType);
        }

    },

    DEL: (state, id) => {
        console.log('DEL 触发');
        for (let i = 0; i < state.questionType.length; i++) {
            if (state.questionType[i].id === id) {
                state.questionType.splice(i, 1);
            }
        }
    }
}
const actions = {
    INIT_NAME: (context) => {
        getTitleName().then(response => {
            console.log(response.data);
            context.commit('INIT', response.data);
        });

    }
}

export default {
    namespaced: true,
    state,
    mutations,
    actions
}